<template>
  <div class="bg_fafafa p-20 w_full h_full">
    <el-button size="small" class="mb-20" @click="handleBack">返回</el-button>
    <div class="bg_fff p-24">
      <div class="flexbetween">
        <div class="f-14">客服考勤</div>
        <div class="flex">
          <div
            v-for="(item, index) in dayList"
            :key="index"
            class="dayitem mr-10 commhover f-14 flexcenter"
            :class="{ active: queryParams.day == item.num }"
            @click="handleDay(item)"
          >
            {{ item.name }}
          </div>
          <el-date-picker
            v-model="times"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            size="small"
          >
          </el-date-picker>
          <select-tree
            size="small"
            :treeList="treeList"
            nodeKey="id"
            :defaultData="defaultData"
            :treeProps="{
              children: 'children',
              label: 'label',
            }"
            @handleNodeClick="selectDrop"
            style="width: 200px"
            class="ml-10"
          />
          <el-select
            v-model="queryParams.status"
            size="small"
            placeholder="筛选状态"
            style="width: 150px"
            class="ml-10"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-button size="small" class="ml-10" @click="handleBack"
            >导出</el-button
          >
          <!-- <el-popover placement="right" width="560" trigger="click">
            <div class="popbox">
              <div class="popheader f-14">自定义列表项</div>
              <div class="flex flexwrap">
                <el-checkbox
                  v-for="(item, index) in tableColumnList"
                  :key="index"
                  v-model="item.show"
                  :label="item.title"
                  >{{ item.title }}</el-checkbox
                >
              </div>
            </div>
            <el-button slot="reference" size="small" class="ml-10"
              ><i class="el-icon-setting f-15"></i
            ></el-button>
          </el-popover> -->
        </div>
      </div>

      <el-table
        v-loading="loading"
        class="commtable chattable mt-20"
        :data="tableList"
      >
        <template v-for="(item, index) in tableColumnList">
          <el-table-column
            :key="index"
            :label="item.title"
            min-width="130px"
            :prop="item.prop"
            :fixed="item.fixed"
            v-if="item.show"
          >
            <template slot-scope="scope">
              <div v-if="item.prop == 'status'">
                <svg-icon
                  v-if="scope.row.status == 1"
                  icon-class="sonline"
                  class-name="mr-5 f-14"
                />
                <svg-icon
                  v-if="scope.row.status == 2"
                  icon-class="leave"
                  class-name="mr-5 f-14"
                />
                <svg-icon
                  v-if="scope.row.status == 3"
                  icon-class="offline"
                  class-name="mr-5 f-14"
                />
                <span>上班</span>
              </div>
              <div v-else>
                {{ scope.row[item.prop] || "-" }}
              </div>
            </template>
          </el-table-column>
        </template>
        <template slot="empty">
            <TableEmpty />
          </template>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>
<script>
import SelectTree from "@/components/SelectTree";
export default {
  data() {
    return {
      queryParams: {
        day: 1,
        pageNum: 1,
        pageSize: 10,
      },
      tableList: [{ID:1, name: "贝贝", status: 1, num: 0 }],
      total: 0,
      loading: false,
      dayList: [
        { name: "今天", num: 1 },
        { name: "昨天", num: 2 },
        { name: "7天", num: 7 },
        { name: "30天", num: 30 },
      ],
      times: "",
      treeList: [
        {
          id: 1,
          label: "一级 1",
          children: [
            {
              id: 2,
              label: "二级 1-1",
              children: [
                {
                  id: 3,
                  label: "三级 1-1-1",
                },
              ],
            },
          ],
        },
        {
          id: 4,
          label: "一级 2",
          children: [
            {
              id: 5,
              label: "二级 2-1",
              children: [
                {
                  id: 6,
                  label: "三级 2-1-1",
                },
              ],
            },
            {
              id: 7,
              label: "二级 2-2",
              children: [
                {
                  id: 8,
                  label: "三级 2-2-1",
                },
              ],
            },
          ],
        },
      ],
      defaultData: {
        value: "",
        name: "",
      },
      options: [
        { label: "上班", value: 1 },
        { label: "离开", value: 2 },
        { label: "下班", value: 3 },
      ],
      checkList: [],
      tableColumnList: [
        { title: "子账号ID", prop: "ID", fixed: true, show: true },
        { title: "客服姓名", prop: "name", fixed: true, show: true },
        { title: "当前状态", prop: "status", fixed: false, show: true },
        { title: "所在分组", prop: "group", fixed: false, show: true },
        { title: "在线时长", prop: "num", fixed: false, show: true },
        { title: "上班时间", prop: "num", fixed: false, show: true },
        { title: "下班时间", prop: "num", fixed: false, show: true },
        { title: "上班时长", prop: "num", fixed: false, show: true },
        { title: "离开时长", prop: "num", fixed: false, show: true }
      ],
    };
  },
  components: {
    SelectTree,
  },
  methods: {
    getList() {},

    handleBack() {
      this.$router.back();
    },

    handleDay(item) {
      this.queryParams.day = item.num;
    },

    selectDrop(val) {
      this.defaultData.value = val;
    },
  },
};
</script>

<style lang="scss" scoped>
.dayitem {
  height: 32px;
  line-height: 32px;
  width: 50px;
  background-color: #f4f6f8;
  &.active {
    background-color: #3070ff !important;
    color: #fff !important;
  }
}
.chattable {
  ::v-deep .el-table__header th {
    background-color: #f5f5f5;
    padding: 16px 0;
  }
}
.popheader {
  border-bottom: 1px solid #e9e9e9;
}
.popbox {
  .el-checkbox {
    width: 33%;
    margin-right: 0;
    margin-top: 5px;
  }
}
</style>
